package calorie.com.calorie.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import calorie.com.calorie.R;
import calorie.com.calorie.activity.NoticeListActivity;
import calorie.com.calorie.response.NoticeResponse;

public class NoticeAdapter extends BaseAdapter {
    private Context context;
    private List<NoticeResponse.DataBean> beans;

    public NoticeAdapter(Context context, List<NoticeResponse.DataBean> beans) {
        this.context = context;
        this.beans = beans;
    }

    @Override
    public int getCount() {
        return beans.size();
    }

    @Override
    public Object getItem(int position) {
        return beans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.item_notice, null);
        TextView title = convertView.findViewById(R.id.tv_notice_content);
        title.setText(beans.get(position).getTitle());
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, NoticeListActivity.class));
            }
        });
        return convertView;
    }
}
